package com.pan.draw;

import com.pan.draw.xy.CircleXY;
import com.pan.draw.xy.RectangleXY;

import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Supplier;

public class EntityGraph {


    private AtomicInteger circleId = new AtomicInteger(1);
    private Integer graphWidth = 700;
    private Integer num;
    private CircleXY circleXY;
    private RectangleXY rectangleXY;

    public EntityGraph(Supplier<Integer[]> graphXY,Integer num){
        this.num = num;
        Supplier<Integer[]> getXY = () -> new Integer[]{graphXY.get()[0]+graphWidth*num,graphXY.get()[1]};
        circleXY = new CircleXY(getXY);
        rectangleXY = new RectangleXY(getXY);
    }
    public EntityGraph(Integer num){
        this.num = num;
        Supplier<Integer[]> getXY = () -> new Integer[]{graphWidth*num,0};
        circleXY = new CircleXY(getXY);
        rectangleXY = new RectangleXY(getXY);
    }

    public Integer getNum() {
        return num;
    }

    public Integer[] getCircleNextXY(){
        return circleXY.getNextXY();
    }
    public Supplier getCircleNextXY = () -> circleXY.getNextXY();

    public Integer[] getRectangleXY(){
        return rectangleXY.getRectangleXY();
    }

    public Supplier getRectangleXY = () -> rectangleXY.getRectangleXY();

    public Integer getNextCircleId(){
        return circleId.getAndIncrement();
    }

}
